home *** CD-ROM | disk | FTP | other *** search
- From: hickeyr@ibm.net (Rich Hickey)
- Message-ID: <4gcjhn$399u@news-s01.ny.us.ibm.net>
- X-Original-Date: 20 Feb 1996 13:49:43 GMT
- Path: in1.uu.net!bounce-back
- Date: 21 Feb 96 07:06:18 GMT
- Approved: fjh@cs.mu.oz.au
- Organization: -
- Newsgroups: comp.std.c++
- Subject: Re: Q: Generic Callbacks -- "Object->*func(...)"
- References: <4fti32$p3p@bcarh8ab.bnr.ca> <4g0csh$dq5@news.bridge.net>
- X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMSrGmeEDnX0m9pzZAQFp0QGAhoUIcRKI5vnd639iRoejhSs9QmHzZLQ8
- dHzXD5mFAv2zAR92UodXFcRxEApvlcFL
- =b7MV
-
- [Moderator's note: my apologies for letting this thread continue,
- since it has strayed from the topic of C++ standardization. I
- approved this article since I think it would be unfair to deny the
- poster a right of reply in this case (perhaps I shouldn't have
- approved the article to which he is replying). Anyway, please try to
- make our job as moderators easier by making sure that articles
- submitted are appropriately focussed for this group. -fjh.]
-
- In message <312495AD.757A@ebc.ericsson.se> - Bjorn Fahller
- <ebcbear@ebc.ericsson.se> writes:
- :>
- :>David Byrden <100101.2547@compuserve.com> wrote:
- :>>
- :>> >> I'd like to be able to call "DoIt" with any type of object and a
- :>> >> pointer to any of that object's member functions that match the
- :>> >> 'parmlist'
- :>>
- :>> In the C++ Report, February 1995, Richard Hickey suggested a library of
- :>> universal callback functors which would encapsulate both an object
- :>> reference and a pointer to a member function of that object.
- :>>
- :>> The caller, and the provider of the callback, would not have to share
- :>> any type information other than the callback library itself.
- :>
- :>Unfortunately the implementation is all but clean, and depends
- :>heavily on the compiler used. Internally, everything is
- :>casted to void*. When I tried the implementation on Sun SparcWorks,
- :>it failed, since pointer to member functions cannot be casted
- :>to void* without severe loss of precision (they're twise
- :>as long as void*.)
- :>
- :>The ideas are still usable, though. Those who are interested
- :>can e-mail me for a simple example (not quite as slick as the
- :>original, but not compiler dependant since it doesn't use
- :>ugly casts.)
- :> _
- :>/Bjorn.
-
- Unfortunately you must not have understood the implementation.
- I admit it is complex, difficult-to-read C++ code, yet it is
- quite clean, and at no point are ptrs-to-members cast to void*.
- If it doesn't work with your compiler I suggest your compiler
- is broken.
-
- I suggest you re-read the source quite carefully and make sure
- you understand it before you criticize it. The callback library
- is being used successfully by many experienced C++ developers.
- No one has reported a language-level problem with it.
-
- Anyone interested in the library source can decide for
- themselves. It is freely available at:
- http://ourworld.compuserve.com/HomePages/RichHickey
-
- Rich Hickey
- ---
- [ To submit articles: try just posting with your news-reader.
- If that fails, use mailto:std-c++@ncar.ucar.edu
- FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
- Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu.
- ]
-